-
-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve device selection #3005
Improve device selection #3005
Conversation
92d74c9
to
c0bc183
Compare
This sounds ideal 👌 matches the muscle memory from using |
Thank you for your feedback. On the other hand, these |
bf16261
to
47ec09b
Compare
I changed to |
Since the previous commit, if a serial is given via -s/--serial (either a real USB serial or an IP:port), a device is selected if its serial matches exactly. In addition, if the user pass an IP without a port, then select any device with this IP, regardless of the port (so that "192.168.1.1" matches any "192.168.1.1:port"). This is also the default behavior of adb. PR #3005 <#3005>
If several devices are connected (as listed by `adb devices`), it was necessary to provide the explicit serial via -s/--serial. If only one device is connected via USB (respectively, via TCP/IP), it might be convenient to select it automatically. For this purpose, two new options are introduced: - -d/--select-usb: select the single device connected over USB - -e/--select-tcpip: select the single device connected over TCP/IP PR #3005 <#3005>
Currently, if several devices are connected,
scrcpy
fails with:This is not very user-friendly: the user must call
adb devices
manually to get the serial, then callscrcpy -s xxxxxxxxxx
explicitly.This PR brings features to improve device selection.
If several devices are connected, scrcpy prints the list of devices:
So it is possible to immediately call scrcpy again with
-s
.In addition, two new options allow to select a USB or TCP/IP device when there is only one connected:
-d
(or--select-usb
) uses a USB device (likeadb -d
)-e
(or--select-tcpip
) uses a TCP/IP device (likeadb -e
)For example, to run
scrcpy
with the single TCP/IP device:To run
scrcpy
with a single USB device:Since there are several devices connected over USB in this example, it fails, with a detailed error message.
Notice that the list of devices is printed at
DEBUG
level if it works (so it is not printed in release mode unless-Vdebug
is passed), whereas it is printed atERROR
level if it fails.(Maybe we should print it at
INFO
level when everything works, so that it is always printed?)The first commits implement the same behavior for listing USB devices for HID/OTG mode (introduced in v1.22:
Do not conflate
--select-tcpip
with the--tcpip
option introduced in v1.21.--tcpip
(without argument):-s
, even-U
or-T
)adb tcpip 5555
)adb shell ip route
)adb connect IP:5555
)--select-tcpip
just selects a device already connected (i.e. listed inadb devices
) via TCP/IPIn hindsight, maybe
--tcpip
should have been called--connect-tcpip
or similar to avoid confusion, but it's too late.